﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DotNet.Business;
using DotNet.Model;
using DotNet.Common;
public partial class Admin_addRecruitment : System.Web.UI.Page
{
    jobBll jBll = new jobBll();
    protected void Page_Load(object sender, EventArgs e)
    {   
        if (Request.QueryString["action"]!=null)
        {
            string action = Request.QueryString["action"].ToString();
            switch (action.Trim())
            {
                case "insert":
                    Insert();
                    break;
                case"load":
                    loadRec();
                    break;
                default:
                    break;
            }
        }
    }

    #region 添加招聘
    public void Insert() 
    {
        job jobModel = new job();
        jobModel.jobClass = Request.Form["jobClass"].ToString();
        if (jobModel.jobClass=="")
        {
            Response.Write("职位名称不能为空！");
            Response.End();
        }
        jobModel.jobNeed = Request.Form["jobNeed"].ToString();
        jobModel.jobSex = Request.Form["job_sex"].ToString();
        jobModel.jobBuMen = Request.Form["jobBuMen"].ToString();
        jobModel.jobNum = Request.Form["jobNum"].ToString();       
        jobModel.jobTimes = Request.Form["jobTimes"].ToString();
        jobModel.jobStu = Request.Form["jobStu"].ToString();
        jobModel.jobRegion = Request.Form["jobRegion"].ToString();
        jobModel.jobInfo =Server.HtmlDecode(Request.Form["FCKeditor1"].ToString());
        if (jobModel.jobInfo=="")
        {
            Response.Write("请填写要求与待遇！");
            Response.End();
        }
        jobModel.jobPeople = Request.Form["jobPeople"].ToString();
        jobModel.jobTel = Request.Form["jobTel"].ToString();
        jobModel.jobFax = Request.Form["jobFax"].ToString();
        jobModel.jobEmail = Request.Form["jobEmail"].ToString();
        jobModel.jobAddress = Request.Form["jobAddress"].ToString();
        if (jobModel.jobPeople==""||jobModel.jobTel==""||jobModel.jobEmail==""||jobModel.jobAddress=="")
        {
            Response.Write("请填写完整的联系方式！");
            Response.End();
        }
        if (Request.Form["jobId_hid"].ToString()!="")
        {
            jobModel.jobId = Convert.ToInt32(Request.Form["jobId_hid"]);
            if (jBll.Update(jobModel))
            {
                Response.Write("2");
            }
            else 
            {
                Response.Write("修改失败！");
            }
        }
        else 
        {
            if (jBll.Insert(jobModel))
            {
                Response.Write("1");
            }
            else
            {
                Response.Write("添加失败！");
            }
        }
       
        Response.End();
    }
    #endregion

    #region 编辑加载信息
    public void loadRec() 
    {
        int Jid = Convert.ToInt32(Request.QueryString["jobId"]);
        job jobModel = jBll.GetModel(Jid);
        this.jobClass.Value = jobModel.jobClass;
        this.jobNeed.Value = jobModel.jobNeed;
        this.jobBuMen.Value = jobModel.jobBuMen;        
        this.jobNum.Value = jobModel.jobNum;
        this.job_sex.Value = jobModel.jobSex;
        jobTimes.Value = jobModel.jobTimes;
        jobStu.Value = jobModel.jobStu;
        jobRegion.Value = jobModel.jobRegion;
        this.FCKeditor1.Value = jobModel.jobInfo;
        this.jobPeople.Value =jobModel.jobPeople;
        this.jobTel.Value = jobModel.jobTel;
        this.jobFax.Value = jobModel.jobFax;
        this.jobEmail.Value = jobModel.jobEmail;
        this.jobAddress.Value = jobModel.jobAddress;
        this.jobId_hid.Value =jobModel.jobId.ToString();
    }
    #endregion
}
